<template>
  <div id="app">
    <router-view/>
  </div>
</template>

<script>
export default {
  name: 'App',
  created () {
  	if ( this.$cookie.get ( 'id' ) ) {
  		this.$store.commit ( 'partnerId', this.$cookie.get ( 'id' ));
  	}
  },
  mounted: function() {
    if ( this.$cookie.get ( 'id' ) ) {
  		this.$store.commit ( 'partnerId', this.$cookie.get ( 'id' ));
  	}
    switch (this.$route.name) {
      case "store":
        this.navbg = 0;
        break;
      case "userMan":
        this.navbg = 1;
        this.$router.push({
        path: "/main/userMan"
      });
        break;
      case "activity":
        this.navbg = 2;
        this.$router.push({
        path: "/main/activity"
      });
        break;
        case "finance":
        this.navbg = 3;
        this.$router.push({
        path: "/main/finance"
      });
        break;
    }
  },
  watch: {
  	$route (to, from) {
  		if(!this.$store.state.partnerId){
        this.$router.push({
            path:'/'
        })
      }else if(this.$cookie.get('partnerPwd') === 'yunlehui2019' && to.path != '/cpass'){
        this.$router.push({
            path:'/cpass'
        })
      }
    }

  }
}
</script>

<style>
html,body{
  margin: 0;
  padding: 0;
}
</style>
